Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 18: Controlling Texture Mapping

../ch18/18fig24.gif
Figure 18.24

A rotated grillwork texture image mapped to a rectangular face to create a chain-link fence.

18fig24.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
    children [
    # Chain-link fence
        Shape {
            appearance Appearance {
                material Material { }
                texture ImageTexture {
                    url "grill.png"
                }
                textureTransform TextureTransform {
                    rotation 0.785
                    scale 32.0 8.0
                    center 0.5 0.5
                }
            }
            geometry IndexedFaceSet {
                solid FALSE
                coord Coordinate {
                    point [
                        -4.0 -1.0 0.1,   4.0 -1.0 0.1,
                         4.0  1.0 0.1,  -4.0  1.0 0.1,
                    ]
                }
                coordIndex [ 0, 1, 2, 3 ]
                texCoord TextureCoordinate {
                    point [
                        0.0 0.0,  1.0 0.0,
                        1.0 1.0,  0.0 1.0,
                    ]
                }
                texCoordIndex [ 0, 1, 2, 3 ]
            }
        },
    # Fence posts
        DEF Post Shape {
            appearance Appearance {
                material Material { }
            }
            geometry Cylinder {
                height 2.0
                radius 0.1
            }
        },
        Transform { translation -4.0 0.0 0.0  children USE Post },
        Transform { translation  4.0 0.0 0.0  children USE Post }
    ]
}